﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Data.SqlClient;

namespace 玩具商城管理系统
{
    public partial class Tcommodity : Form
    {
        public Tcommodity()
        {
            InitializeComponent();
        }

        private void label1_Click(object sender, EventArgs e)
        {

        }

        private void Tcommodity_Load(object sender, EventArgs e)
        {
            DB.GetCn();
            string str="" ;
            if(newwin.Commodityid!="")
            {
                 str = "select * from commodity where commodity_id=" + newwin.Commodityid + "";
            }
            else if(newwin.Commodityid!="")
            {

                str = "select * from commodity where commodity_id=" + Form1.Commodityid + "";
            }
            else
            {
                str = "select * from commodity where commodity_id=" + znew.订购.Commodityid + "";
            }
            DataTable dt = DB.GetDataSet(str);

            commodity_id.Text = Form1.Commodityid;
            commodity_name.Text = dt.Rows[0][1].ToString();
            commodit_money.Text = dt.Rows[0][2].ToString();
            commodity_invent.Text = dt.Rows[0][3].ToString();   
            commodity_book.Text = dt.Rows[0][4].ToString();
            commodity_desc.Text = dt.Rows[0][5].ToString();
            sort_name.Text= dt.Rows[0][6].ToString();
            try
            {
                pictureBox1.Image = Image.FromFile(Application.StartupPath + dt.Rows[0][8].ToString());
                pictureBox1.SizeMode = PictureBoxSizeMode.StretchImage;
            }
            catch
            {
                pictureBox1.Image = Image.FromFile(Application.StartupPath + "\\" + "暂无图片.gif.jpg");
                pictureBox1.SizeMode=PictureBoxSizeMode.StretchImage;
            }
        }

        private void button1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void label11_Click(object sender, EventArgs e)
        {
            znew.Tcommoditypj pj = new znew.Tcommoditypj();
            pj.ShowDialog();
        }
    }
}
